﻿/**
 * @file logger.h
 * @author Yunfeng.Bo (Yunfeng.Bo@gmaile.com)
 * @brief 基于 boost.log 实现的日志功能，使用时先调用 make_logger 方法创建日志。
 * @version 0.1
 * @date 2021-02-22
 *
 * @copyright Copyright (c) 2021
 *
 */

#pragma once

#include <boost/log/expressions.hpp>
#include <boost/log/support/date_time.hpp>
#include <boost/log/trivial.hpp>
#include <boost/log/utility/setup.hpp>

#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/filesystem.hpp>

#define LOG_TRACE BOOST_LOG_TRIVIAL(trace)
#define LOG_DEBUG BOOST_LOG_TRIVIAL(debug)
#define LOG_INFO BOOST_LOG_TRIVIAL(info)
#define LOG_WARNING BOOST_LOG_TRIVIAL(warning)
#define LOG_ERROR BOOST_LOG_TRIVIAL(error)
#define LOG_FATAL BOOST_LOG_TRIVIAL(fatal)

// glog style
#define INFO info
#define LOG(LEVEL) BOOST_LOG_TRIVIAL(LEVEL)

namespace common {
namespace log {
/**
 * @brief Create default log system
 *  to use log:
 *      - LOG_TRACE << "log message";
 *      - LOG_DEBUG << "log message";
 *      - LOG_INFO << "log message";
 *      - LOG_WARNING << "log message";
 *      - LOG_ERROR << "log message";
 *      - LOG_FATAL << "log message";
 *
 * @param dir set log output directory
 * @param filename  set log output file prefix
 */
void make_logger(std::string dir, std::string filename);
}   // namespace log
}   // namespace common